package GUI;

import javax.swing.table.*;

import java.util.ArrayList;

import model.*;
import control.*;

public class clientTable extends DefaultTableModel
{
	private ArrayList<Client> client = new ArrayList<Client>();
	
	public clientTable()
	{
		
	}
	
	@Override
	public boolean isCellEditable(int row, int column)
	{
		return false;
	}
	
	public void setClient(ArrayList<Client> _client)
	{
		client = _client;
		fireTableDataChanged();
	}
	
	public ArrayList<Client> getS()
	{
		return client;
	}
	
	@Override
    public int getColumnCount()
	{
        return 9;
	}
	
	@Override
	public int getRowCount()
	{
		if(client == null)
		{
			return 0;
		}
		else
		{
			return client.size();
		}
	}
	
	@Override
    public String getColumnName(int column)
	{
        String columnName = "";
        switch (column)
        {
            case 0:
                columnName = "Name";
                break;
            case 1:
                columnName = "Address";
                break;
            case 2:
                columnName = "Zipcode";
                break;
            case 3:
                columnName = "City";
                break;
            case 4:
                columnName = "Phone";
                break;
            case 5:
                columnName = "GSM";
                break;
            case 6:
                columnName = "Email";
                break;
            case 7:
                columnName = "CVR";
                break;
            case 8:
            	columnName = "Contact CPR";
            	break;
        }
        return columnName;
    }
	
	@Override
	public Object getValueAt(int row, int column)
	{
		Object value = null;
		switch (column)
		{
		case 0:
			value = client.get(row).getName();
			break;
		case 1:
			value = client.get(row).getAddress();
			break;
		case 2:
			value = client.get(row).getZipCode();
			break;
		case 3:
			value = client.get(row).getCity();
			break;
		case 4:
			value = client.get(row).getPhone();
			break;
		case 5:
			value = client.get(row).getGsm();
			break;
		case 6:
			value = client.get(row).getEmail();
			break;
		case 7:
			value = client.get(row).getCvr();
			break;
		case 8:
			value = client.get(row).getContact().getCpr();
		}
		return value;
	}
}
